﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:WickedFlame.VecDraw.Base.Controls;assembly=VecDraw.Base"
                    xmlns:local="clr-namespace:WickedFlame.Util.Controls">

    <Style TargetType="{x:Type Button}" x:Key="transparentButton">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border BorderThickness="0" Background="Transparent">
                            <ContentPresenter VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
											SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:HeaderedToolItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:HeaderedToolItem}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>

                        <Button Command="local:HeaderedToolItem.ExpandCommand" Background="White" Style="{StaticResource transparentButton}">
                            <Border x:Name="Border" Background="#00FFFFFF" ToolTip="{TemplateBinding Description}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    
                                    <ContentPresenter VerticalAlignment="Center" ContentSource="Icon" HorizontalAlignment="Center" Height="16" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="5,0,6,0"/>

                                    <TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Foreground="WhiteSmoke" VerticalAlignment="Center" FontSize="10" FontWeight="Heavy"/>

                                    <Path Grid.Column="3" SnapsToDevicePixels="True" IsHitTestVisible="False" Name="Arrow" Margin="8,0,8,0" Fill="#0FFF" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Right" VerticalAlignment="Center" Data="M 0 0 L 0 8 L 5 4 Z" Stroke="{TemplateBinding Foreground}" StrokeThickness="0.5">
                                        <Path.RenderTransform>
                                            <RotateTransform Angle="0" />
                                        </Path.RenderTransform>
                                    </Path>
                                </Grid>
                            </Border>
                        </Button>

                        <c:Reveal x:Name="ContentReveal" Grid.Row="1" VerticalReveal="FromTopToBottom" HorizontalReveal="None">
                            <!-- the extra border here is required because Reveal doesn't account for margins -->
                            <Border>
                                <Border BorderThickness="0.5,1,0,0" BorderBrush="#6000" Background="#10FFFFFF" CornerRadius="2,3,2,2" HorizontalAlignment="Center" SnapsToDevicePixels="True" Width="200" Margin="7,0,7,6" >
                                    <Border BorderThickness="0,0,0.5,1" BorderBrush="#20FFFFFF" CornerRadius="2,3,2,2">
                                        <ContentPresenter Grid.Row="1" ContentSource="Content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                    </Border>
                                </Border>
                            </Border>
                        </c:Reveal>

                    </Grid>



                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="Border" Property="IsMouseOver" Value="True" />
                                <Condition Property="IsExpanded" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="Background" Value="#20FFFFFF" />
                            <Setter TargetName="Border" Property="Cursor" Value="Hand" />
                        </MultiTrigger>
                        <Trigger Property="IsExpanded" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation BeginTime="0:0:0.2"  Storyboard.TargetName="ContentReveal" Storyboard.TargetProperty="AnimationProgress" Duration="0:0:0.2" To="1" DecelerationRatio="1" />
                                        <DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" To="90" DecelerationRatio="1" />
                                        <!--<ColorAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)" Duration="0:0:0.2" To="#FFF" DecelerationRatio="1" />-->
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ContentReveal" Storyboard.TargetProperty="AnimationProgress" Duration="0:0:0.2" AccelerationRatio="1" />
                                        <DoubleAnimation  Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" AccelerationRatio="1" />
                                        <!--<ColorAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)" Duration="0:0:0.2" AccelerationRatio="1" />-->
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>